<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%response.setHeader("cache-control","public"); %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<!-- 登录页面 -->
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/common.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/examMng/core.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/login.css">
    <!--bootstrap基础引用 start-->
<script type="text/javascript" src="<%=path%>/static/jstreeview/bootstrap/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="<%=path%>/static/jstreeview/bootstrap/bootstrap.min.js"></script>
<!--bootstrap基础引用 end-->
<!--bootstrap-dialog start-->
<link rel="stylesheet" type="text/css" href="<%=path%>/static/jstreeview/plugins/bootstrap-dialog/bootstrap-dialog.min.css">
<script type="text/javascript" src="<%=path%>/static/jstreeview/plugins/bootstrap-dialog/bootstrap-dialog.min.js"></script>
<!--bootstrap-dialog end-->

     <style type="text/css">
    .floatp{
	    float: right;
	    margin-top: 50px;
	    margin-right: 80px;
    }
    .fontStyle{
	    font-size: 18px;
	    color: #fff;
	    font-weight: bold;
    }
    .vmiddle{
    		background-image: url('<%=path%>/static/images/170.png');
    		height:375px;
     		position:absolute;
            left:0;
            top: 25%;
            bottom: 0;
            right: 0;
            margin: auto;
        }
    .systitle{
		    height:48px;
		    width:100%;
		    text-align: center;
		    font-size:48px;
		    font-weight:  bold;
		    background-image: url('<%=path%>/static/images/logo2.png');
		    background-size: 54px 54px;
		    background-repeat: no-repeat;
		    padding-left: 72px;
    }
    </style>
    <script src="<%=path%>/static/js/respond.js"></script>
    <!--[if !IE]> -->
    <script type="text/javascript">
        window.jQuery || document.write("<script src='<%=path%>/static/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
    </script>
    <!-- <![endif]-->

    <script type="text/javascript">
        window.jQuery || document.write("<script src='<%=path%>/static/js/jquery-1.9.1.min.js'>" + "<" + "/script>");
    </script>
    <script type="text/javascript" src="<%=path%>/static/js/login.js"></script>
    <script type="text/javascript" src="<%=path%>/static/js/jquery.cookie.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            document.onkeydown = function (e) {
                var ev = document.all ? window.event : e;
                if (ev.keyCode == 13) {
                    // 如（ev.ctrlKey && ev.keyCode==13）为ctrl+Center 触发
                    start();
                }
            }
        });

        function goAdmin() {
            window.location.href = "<%=basePath%>sys/index";
        }

        function goMaster() {
            window.location.href = "<%=basePath%>sys/master";
        }

        function goTrainee() {
            window.location.href = "<%=basePath%>sys/trainee";
        }

        function start() {
            var username = $("#username").val();
            var password = $("#password").val();
            var checkCode = $("#checkCode").val();
            $.ajax({
                url: '<%=basePath%>sys/proof/',
                data: {
                    account: username,
                    password: password,
                    code: checkCode
                },
                dataType: "json",
                success: function (data) {

                    if ("1" == data[0].status) {
                        var arr = data[0].role
                        if (arr.length > 1) {
                            var contentDiv = "";
                            if (arr.indexOf(1) > -1) {
                                contentDiv = "<div class='btn btn-info margintopbom' onclick='goAdmin()' style='margin-right: 15px;'><span style='color: #FFFFFF'>"
                                    + "管理员" + "</span><span class='glyphicon glyphicon-cog lineheightx' style='color: #FFFFFF'></span></div>";
                            }
                            if (arr.indexOf(2) > -1) {
                                contentDiv = contentDiv + "<div class='btn btn-info margintopbom' onclick='goMaster()'style='margin-right: 15px;'><span style='color: #FFFFFF'>"
                                    + "工作人员" + "</span><span class='glyphicon glyphicon-user lineheightx' style='color: #FFFFFF'></span></div>";
                            }
                            if (arr.indexOf(3) > -1) {
                                contentDiv = contentDiv + "<div class='btn btn-info margintopbom' onclick='goTrainee()';><span style='color: #FFFFFF'>"
                                    + "学员" + "</span><span class='glyphicon glyphicon-education lineheightx' style='margin-right:0;color: #FFFFFF   '></span></div>";
                            }
                            $("#contentdiv").html(contentDiv);
                            $("#mymodal").modal();

                        } else {
                            if (arr[0] == 1) {
                                window.location.href = "<%=basePath%>sys/index";
                            } else if (arr[0] == 2) {
                                window.location.href = "<%=basePath%>sys/master";
                            } else if (arr[0] == 3) {
                                window.location.href = "<%=basePath%>sys/trainee";
                            } else {
                                window.location.href = "<%=basePath%>sys/index";
                            }
                        }
                    } else {
                    	BootstrapDialog.confirm({
            				title : '提示',
            				message : data[0].error,
            				size : BootstrapDialog.SIZE_SMALL,
            				type : BootstrapDialog.TYPE_DEFAULT,
            				closable : true,
            				btnCancelLabel : '取消',
            				btnOKLabel : '确定'
            			});
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                	BootstrapDialog.confirm({
        				title : '提示',
        				message : '系统错误',
        				size : BootstrapDialog.SIZE_SMALL,
        				type : BootstrapDialog.TYPE_DEFAULT,
        				closable : true,
        				btnCancelLabel : '取消',
        				btnOKLabel : '确定'
        			});
                }
            });
        }

        function refresh() {
            var url = "<%=basePath%>sys/check.jpg?number=" + Math.random();
            $("#img").attr("src", url);
        }

    </script>
</head>
<body>
<!--head begin-->
<div class="container login_logo" style="text-align: center;">
    <!-- <img src="../images/login_logo.png"> -->
   <span class="systitle">在&nbsp;线&nbsp;考&nbsp;试&nbsp;系&nbsp;统</span>
</div>
<!--head end-->

<!--body begin-->
<div class="loginbox">
    <div class="row vmiddle" >
        <div class="col-lg-5 col-md-5 rightmain floatp">
            <div class="rightbg">
                <ul class="login-nav fontStyle" >你好，欢迎使用</ul>
                <div class="login-main">
                    <div class="content-mj" id="login-content1">
                        <form>
                            <div class="form-group has-feedback">
                                <input id="username" type="text" placeholder="请输入帐号" class="form-control"
                                       style="color:#999;">
                                <span class="glyphicon glyphicon-user form-control-feedback" aria-hidden="true"></span>
                                <span class="sr-only">(success)</span>
                            </div>
                            <div class="form-group has-feedback">
                                <input id="password" type="password" placeholder="请输入密码" class="form-control"
                                       style="color:#999;">
                                <span class="glyphicon glyphicon-lock form-control-feedback" aria-hidden="true"></span>
                                <span class="sr-only">(success)</span>
                            </div>
                            <a class="btn btn-success btn-block" onclick="start();" style="background: #4c4ca6;">登录</a>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal" id="mymodal">
    <div class="modal-dialog" style="width:320px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <h4 class="modal-title">您有多个角色, 请选择:</h4>
            </div>
            <div id="content" class="modal-body">
                <div id="contentdiv"></div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

</body>
</html>
